Repository navigation
fix(api-core): handle non-object REST error envelopes - #19254
pradeep-ramola wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request improves error handling in format_http_response_error by safely handling non-object payloads and non-dictionary error fields, preventing potential runtime errors. It also adds comprehensive unit tests to verify these edge cases. The review feedback suggests simplifying the assignment of the error variable to eliminate redundant ternary checks and enhance code readability.
|
I have signed the Google CLA using the commit author email, The check's official "New Contributors" rescan link opens successfully, but submitting its Rescan button returns HTTP 400 (also reproduced in a browser). Could a maintainer help rerun the CLA check or advise on the remaining account linkage? The review suggestion has already been addressed and its thread is resolved. I re-ran the api-core unit and asyncio suites on the current commit: 2,031 passed, one skipped. No code changes were needed for this recheck. |
exceptions.pyhas 100% statement and branch coverageFixes #19253
Summary
Normalize the top-level REST error payload and its
errormember before accessing standard fields. A 503 response such as{"error": null}currently raisesAttributeError, maskingServiceUnavailableand preventing the normal retry predicate from recognizing the failure.Fall back to the existing
unknown errormessage when no standard error object is available. Keep valid error dictionaries, structured details, attached responses, HTTP-status exception selection, and the list-wrapper behavior from #18232 unchanged.Tests
--cov-fail-under=100: 100% statement and branch coverage forgoogle.api_core.exceptions.I202noqa warning intest_grpc_helpers_async.py.git diff --check: pass.No new dependencies, public API changes, or generated files. All HTTP responses are local test objects; no Google Cloud resources or credentials are used.
AI assistance: implementation and local verification used OpenAI Codex.